import {request} from "vendor/utils/T";
import {toApi} from "@/service/proxyApi";
import {RequestDataType, RespDataType} from "./apiType";

export * from "./apiType";

const {get, postJSON, del, put } = request;

/**
 * 获取字典数据分页列表
 */
export const getDictionaryDataPageList = (params: { page: number, pageSize: number, dictType: string, dictLabel?: string }) => {
    return get<RespDataType.DictionaryDataPageList>(toApi("system/dict/data/list"), params);
}

/**
 * 创建字典数据
 */
export const createDictionaryData = (params: RequestDataType.CreateDictionaryDataItem) => {
    return postJSON(toApi("system/dict/data"), params);
}

/**
 * 获取字典数据信息
 */
export const getDictionaryDataInfo = (dictCode: number) => {
    return get<RespDataType.DictionaryDataItem>(toApi("system/dict/data"), {dictCode});
}

/**
 * 更新字典数据信息
 */
export const updateDictionaryData = (dictCode: number, params: Partial<RequestDataType.UpdateDictionaryDataItem>) => {
    return put(toApi(`system/dict/data?dictCode=${dictCode}`), params);
}

/**
 * 删除字典数据信息
 */
export const deleteDictionaryData = (dictCodes: number[]) => {
    return del(toApi(`system/dict/data`), {ids: dictCodes});
}

